var t = getApp();

Page({
    data: {
        active: 0,
        active1: 0,
        details: {},
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        wait_amount: 0,
        settle_amount: 0
    },
    onLoad: function(t) {
        this.getDetails(), this.getListData();
    },
    getDetails: function() {
        var a = this, e = t.getNetAddresss("plugin.dealer-task-reward.frontend.controllers.page.index");
        t._postNetWork({
            url: e,
            success: function(e) {
                var s = e.data;
                if (1 != s.result) return t.tips(s.msg);
                wx.setNavigationBarTitle({
                    title: s.data.plugin_name
                }), a.setData({
                    details: s.data,
                    goods_list: s.data.goods_list
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    swichTabTItem: function(t) {
        this.setData({
            active: t.detail.index
        });
    },
    switchTabStatus: function(t) {
        this.setData({
            active1: t.detail.index
        }), this.getListData();
    },
    gotoRecord: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageI/dealer_task_reward/dealerTaskRewardRecord/dealerTaskRewardRecord?goods_id=".concat(a, "&task_id=").concat(this.data.details.task_id)
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    getListData: function() {
        var a = this;
        this.data.page = 1, this.data.total_page = 0, this.data.isLoadMore = !0;
        var e = t.getNetAddresss("plugin.dealer-task-reward.frontend.controllers.reward.index"), s = {};
        this.data.active1 > 0 && (s.status = this.data.active1), t._getNetWork({
            url: e,
            data: s,
            success: function(e) {
                var s = e.data;
                if (1 != s.result) return t.tips(s.msg);
                a.setData({
                    isLoadMore: !0,
                    total_page: s.data.reward_list.last_page,
                    listData: s.data.reward_list.data,
                    wait_amount: s.data.wait_amount,
                    settle_amount: s.data.settle_amount
                }), a.data.total_page || (a.data.total_page = 0);
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (1 == this.data.active && (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page))) {
            this.data.page++;
            var e = {
                page: this.data.page
            };
            3 != this.data.tabsIndex && (e.status = this.data.tabsIndex);
            var s = t.getNetAddresss("plugin.gratitude-reward.frontend.index.index");
            t._getNetWork({
                url: s,
                data: e,
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        a.data.isLoadMore = !0;
                        var s = e.data.reward_list.data;
                        a.setData({
                            listData: a.data.listData.concat(s)
                        });
                    } else a.data.isLoadMore = !1, a.data.page--;
                }
            });
        }
    },
    onShareAppMessage: function() {}
});